/**
 * 
 */
package adnotatio.common.xml;

/**
 * This is a common superclass for all XML node wrappers.
 * 
 * @author kotelnikov
 */
public class XMLNode {

    /**
     * The XML document corresponding to this node
     */
    final XMLDocument fDocument;

    /**
     * The real wrapped XML node
     */
    final Object fNode;

    /**
     * Initializes this object with the real XML node object
     * 
     * @param document the document owning this node
     * @param node the node to set
     */
    public XMLNode(XMLDocument document, Object node) {
        fDocument = document;
        fNode = node;
    }

    /**
     * @see java.lang.Object#equals(java.lang.Object)
     */
    public boolean equals(Object obj) {
        if (obj == this)
            return true;
        if (!(obj instanceof XMLNode))
            return false;
        XMLNode e = (XMLNode) obj;
        return fNode.equals(e.fNode);
    }

    /**
     * Returns the XML document corresponding to this node
     * 
     * @return the XML document corresponding to this node
     */
    public final XMLDocument getDocument() {
        return fDocument;
    }

    /**
     * @see java.lang.Object#hashCode()
     */
    public int hashCode() {
        return fNode.hashCode();
    }

    /**
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return fNode.toString();
    }

}
